#include "main.h"
int BitsInChar (unsigned char *buf_in,unsigned char *buf_out,str_inf_dec * inf)
{
	while (inf->cur_pos < inf->max_pos)
	{
		if (inf->ind_char < SIZE_BUF)
		{
			if ((inf->ind_bit < (8 - (inf->u_bits))) || ((inf->cur_pos < (inf->max_pos - 1)) && (inf->ind_bit < 8)))
			{
				if (buf_in[inf->cur_pos] & (__MARKER_ >> inf->ind_bit))
					inf->elm = inf->elm->right;
				else
					inf->elm = inf->elm->left;
				if (!inf->elm->flag)	{
					buf_out [inf->ind_char] = inf->elm->alpha;
					inf->elm = inf->head;
					inf->ind_char++;
				}
				inf->ind_bit++;
			}	else	{
				inf->cur_pos++;
				inf->ind_bit = 0;
			}
		}	else	{
				return NEW_BUF_OUT;
		}
	}
	if ( (inf->cur_pos == inf->max_pos) && (inf->ind_char == SIZE_BUF))
	{
		return NEW_DATA;
	} else {
		if (inf->cur_pos == inf->max_pos)
			return NEW_BUF_IN;
	}
	return -4;
}
